/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.yczbj.ycvideoplayer.ability;

import ohos.aafwk.ability.fraction.FractionManager;
import ohos.aafwk.ability.fraction.FractionScheduler;
import ohos.aafwk.content.Intent;

import org.yczbj.ycvideoplayer.ResourceTable;
import org.yczbj.ycvideoplayer.fraction.RecyclerView2Fragment;
import org.yczbj.ycvideoplayer.fraction.RecyclerViewAutoPlayFragment;
import org.yczbj.ycvideoplayer.fraction.RecyclerViewFragment;
import org.yczbj.ycvideoplayer.fraction.SeamlessPlayFragment;
import org.yczbj.ycvideoplayer.fraction.TikTok1ListFragment;
import org.yczbj.ycvideoplayer.fraction.TikTokListFragment;

/**
 * 6.1 在fragment的列表播放
 * 6.2 在fragment的列表播放，自动播放
 * 6.3 在列表中播放，类似抖音，使用ViewPager
 * 6.4 在列表中播放，类似抖音，使用RecyclerView
 * 6.5 在fragment的列表播放无缝切换
 * 6.6 在列表播放，一次滑动一个item
 *
 * @since 2021-05-10
 */
public class TestListAbility extends BaseAbility {
    @Override
    protected int getLayoutResId() {
        return ResourceTable.Layout_ability_test_fragment;
    }

    @Override
    protected void initComponent(Intent intent) {
        super.initComponent(intent);
        int type = intent.getIntParam("type", 0);
        FractionManager fractionManager = getFractionManager();
        FractionScheduler scheduler = fractionManager.startFractionScheduler();
        if (type == 0) {
            scheduler.replace(ResourceTable.Id_container, new RecyclerViewFragment());
        } else if (type == 1) {
            scheduler.replace(ResourceTable.Id_container, new RecyclerViewAutoPlayFragment());
        } else if (type == 2) {
            scheduler.replace(ResourceTable.Id_container, new TikTokListFragment());
        } else if (type == 3) {
            scheduler.replace(ResourceTable.Id_container, new TikTok1ListFragment());
        } else if (type == 4) {
            scheduler.replace(ResourceTable.Id_container, new SeamlessPlayFragment());
        } else {
            scheduler.replace(ResourceTable.Id_container, new RecyclerView2Fragment());
        }
        scheduler.submit();
    }
}
